<!DOCTYPE html>
<html>
<head>
	<link href="css/style.css" rel="stylesheet" type="text/css">
	<script language="javascript" src="js/lib/jquery-1.7.2.js"></script>
	<script language="javascript" src="js/yh.const.js"></script>
	<script language="javascript" src="js/yh.math.js"></script>
	<script language="javascript" src="js/yh.engine.js"></script>
	<script language="javascript" src="js/yh.items.js"></script>
	<script language="javascript" src="js/yh.places.js"></script>
	<script language="javascript" src="js/yh.controls.js"></script>
	<script language="javascript">
		$(function() {
			$('#loading').css("width", YHConstants.layout.width + "px");
			$('#loading').css("height", YHConstants.layout.height + "px");
			$('#loading').css("left", Math.max(0, (($(window).width() - $('#loading').outerWidth()) / 2) + $(window).scrollLeft()) + "px");
			YumeHikkiEngine.Wrapper = $('#wrapper');
			YumeHikkiEngine.Wrapper.css('width', YumeHikkiEngine.getWidth() + "px");
			YumeHikkiEngine.Wrapper.css('height', YumeHikkiEngine.getHeight() + "px");

			YumeHikkiEngine.Scene = new YHRoom('demo_room').setLeftLocation("demo_room").setRightLocation("demo_room");
			YumeHikkiEngine.Scene.Draw();
			
			var recycle1 = new YHFurniture("worlds/" + YumeHikkiEngine.Scene.getTitle() + "/recycle1.png");
			recycle1.setTop(100).setLeft(100).setWidth(87).setHeight(129).setThickness(20);
			recycle1.Action = function(){
				this.Hide();
			};
			recycle1.Draw();
			
			var door1 = new YHDoor("demo_room").setImage("worlds/" + YumeHikkiEngine.Scene.getTitle() + "/recycle2.png");
			door1.setTop(100).setLeft(300).setWidth(87).setHeight(129).setThickness(20).setTitle("door1");
			door1.Draw();
			
			var wall_left = new YHWall("worlds/" + YumeHikkiEngine.Scene.getTitle() + "/wall_diag_right.png");
			wall_left.setTop(200).setLeft(200).setWidth(150).setHeight(150).setDiagonal(YHConstants.diagonal.left_to_right).setWallThickness(20).setZIndex(300);
			wall_left.Draw();
			var wall_center = new YHWall("worlds/" + YumeHikkiEngine.Scene.getTitle() + "/wall_hor.png");
			wall_center.setTop(260).setLeft(325).setWidth(300).setHeight(90).setThickness(20).setZIndex(301);
			wall_center.Draw();
 			var wall_right = new YHWall("worlds/" + YumeHikkiEngine.Scene.getTitle() + "/wall_diag_left.png");
			wall_right.setTop(200).setLeft(600).setWidth(150).setHeight(150).setDiagonal(YHConstants.diagonal.right_to_left).setWallThickness(20).setZIndex(300);
			wall_right.Draw();
			
			//loading player's character
			YumeHikkiEngine.Player = new YHPlayer();
			var playerX = $.getUrlVar('x');
			var playerY = $.getUrlVar('y');
			var doorItem = $.getUrlVar('item');
			if (playerX != null && playerY != null && isUFloatRegExp(playerX) && (isUFloatRegExp(playerY)))
			{
				playerX = parseFloat(playerX) - YumeHikkiEngine.Player.getWidthHalf();
				playerY = parseFloat(playerY) - YumeHikkiEngine.Player.getHeight();
			}
			else if(doorItem)
			{
				doorItem = YumeHikkiEngine.getItemByTitle(doorItem);
				if(doorItem)
				{
					playerX = doorItem.getLeft() + doorItem.getWidthHalf() - YumeHikkiEngine.Player.getWidthHalf();
					playerY = doorItem.getBottom() - YumeHikkiEngine.Player.getHeightHalf() + YHConstants.door.space;
				}
			}
			else
			{
				playerX = YumeHikkiEngine.Scene.getStartX();
				playerY = YumeHikkiEngine.Scene.getStartY();
			}
			YumeHikkiEngine.PutPlayer(playerX, playerY);
			YumeHikkiEngine.CanMove(YumeHikkiEngine.Player, playerX, playerY);
			//preload images
			if (document.images) {
				var meRight = new Image();
				var meLeft = new Image();
				var meUp = new Image();
				var meDown = new Image();
				meRight.src = "pic/me/me-right.png";
				meLeft.src = "pic/me/me-left.png";
				meUp.src = "pic/me/me-up.png";
				meDown.src = "pic/me/me-down.png";
			}
			$('#wrapper').css("left", Math.max(0, (($(window).width() - $('#wrapper').outerWidth()) / 2) + $(window).scrollLeft()) + "px");
			$('#think').css("left", Math.max(0, (($(window).width() - $('#think').outerWidth()) / 2) + $(window).scrollLeft()) + "px");
			$('#textarea').css("left", Math.max(0, (($(window).width() - $('#textarea').outerWidth()) / 2) + $(window).scrollLeft()) + "px");
			$('#repository').css("left", Math.max(0, (($(window).width() - $('#repository').outerWidth()) / 2) + $(window).scrollLeft()) + "px");
			$('#loading').fadeOut('slow');
		});
	</script>
</head>
<body>
<div id="loading" class="">
	<h1>Yume Hikki</h1>
	<img src="pic/me/me-logo.png" align="right"/>
	<p><strong>Lives here:</strong> <a href="http://yume-hikki.googlecode.com/">Yume Hikki</a></p>
	<p><strong>Github:</strong> <a href="https://github.com/rikkimongoose/yumehikki">Yume Hikki Project</a></p>
	<p><strong>Idea, coding, art:</strong> <a href="http://rikki-mongoose.blogspot.com/">Rikki Mongoose</a></p>
	<p><strong>Art:</strong> <a href="http://www.shutterstock.com/cat.mhtml?lang=en&search_source=search_form&version=llv1&anyorall=all&safesearch=1&searchterm=&search_group=&orient=&search_cat=&searchtermx=&photographer_name=novkota1&people_gender=&people_age=&people_ethnicity=&people_number=&commercial_ok=&color=&show_color_wheel=1&secondary_submit=Search">kota</a></p>
	<p><strong>Music:</strong> <a href="http://gr-oborona.ru/">Egor Letov</a></p>
</div>
<div id="wrapper">
</div>
<div id="think" class="message think hide">
	I think, I'm paranoid.
</div>
<div id="textarea" class="message textarea hide">
	<p>Madotsuki meets many different and bizarre characters in her dreams, ranging from ordinary people and animals, through frighteningly weird creatures to giant eldritch monsters.</p>
	<p>The strange behaviour and expressions of the characters in Yume Nikki seem to exhibit certain personality traits. They influence a lot of the atmosphere of the game, even if they don't actually do much at all.</p>
	<p>Many characters play particular role in the game. Some give Madotsuki effects when she interacts with them, whereas others may teleport her to a completely different place. Others may ignore Madotsuki completely and simply loiter in the deranged world of her dreams.</p>
	<p>Note: None of the characters, excluding Madotsuki, have official names. All dream characters were named by the fan community, and many characters have not yet been named (See talk page). </p>
</div>
<div id="repositoty" class="message inventory hide">
	No items here
</div>
</body>
</html>